home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / Text / Edit / Vim / doc / windows.doc < prev    next >
Text File  |  1994-08-12  |  15KB  |  435 lines

  1. Editing with multiple windows and buffers.
  2.  
  3. Explained here are commands have been added to use multiple windows and
  4. buffers. Additionally there are explanations for commands that work different
  5. when used in combination with more than one window.
  6.  
  7.  
  8. A window is a viewport onto a buffer. You can use multiple windows on one
  9. buffer. Or several windows on different buffers.
  10.  
  11. A buffer is a file loaded into memory for editing. The original file remains
  12. unchanged until you write the buffer to the file.
  13.  
  14. A buffer can be in one of three states:
  15.  
  16. active:   The buffer is displayed in a window. If there is a file for this
  17.       buffer it has been read into the buffer. The buffer may have been
  18.       modified.
  19. hidden:   The buffer is not displayed. If there is a file for this buffer it
  20.           has been read into the buffer. The buffer may have been modified.
  21. inactive: The buffer is not displayed and does not contain anything. Options
  22.           for the buffer are remembered if the file was once loaded.
  23.  
  24. In a table:
  25.  
  26. state        displayed    loaded        :buffers
  27.         in window             shows
  28. active          yes         yes          ' '
  29. hidden          no         yes          'h'
  30. inactive      no         no          '-'
  31.  
  32.  
  33. Starting Vim
  34. -----------
  35.  
  36. By default Vim starts with one window, just like vi.
  37.  
  38. The "-o" command line argument can be used to open a window for each file in
  39. the argument list: "Vim -o file1 file2 file3" will open three windows.
  40.  
  41. "-oN", where N is a decimal number, opens N windows. If there are more file
  42. names than windows, only N windows are opened, some files do not get a window.
  43. If there are more windows than file names, the last few windows will be
  44. editing empty buffers.
  45.  
  46. If there are many file names the windows will become very small. You might
  47. want to set the 'winheight' option to create a workable situation.
  48.  
  49.  
  50. Opening a new window
  51. --------------------
  52.  
  53. CTRL-W s
  54. CTRL-W S
  55. CTRL-W CTRL-S
  56. :[N]split
  57.         Split current window in two. The result is two viewports on
  58.         the same file. Make new window N high (default is to use half
  59.         the height of the current window). Reduces the current window
  60.         height to create room (and others, if the 'equalalways' option
  61.         is set).
  62.  
  63. CTRL-W n
  64. CTRL-W CTRL_N
  65. :[N]new
  66.         Create a new window and start editing an empty file in it.
  67.         Make new window N high (default is to use half the existing
  68.         height). Reduces the current window height to create room (and
  69.         others, if the 'equalalways' option is set). 
  70.  
  71. :[N]new [+command] fname
  72. :[N]split [+command] fname
  73.         Create a new window and start editing file fname in it. If
  74.         [+command] is given, execute the command when the file has
  75.         been loaded. Make new window N high (default is to use half
  76.         the existing height). Reduces the current window height to
  77.         create room (and others, if the 'equalalways' option is set).
  78.  
  79.  
  80. Closing a window
  81. ----------------
  82.  
  83. CTRL-W q
  84. CTRL-W CTRL-Q
  85. :quit        Quit current window, unless the buffer was changed and there
  86.         are no other windows for this buffer. When quitting the last
  87.         window, exit Vim.
  88.  
  89. :quit!        Quit current window. If this was the last window for a buffer,
  90.         any changes to that buffer are lost. When quitting the last
  91.         window, exit Vim. 
  92.  
  93. CTRL-W c
  94. :close        Quit current window, unless it is the last window on the
  95.         screen. The buffer becomes hidden (unless there is another
  96.         window editing it). (Note: CTRL-W CTRL-C does not work).
  97.  
  98. CTRL-W o
  99. CTRL-W CTRL-O
  100. :only        Make the current window the only one on the screen. All other
  101.         windows are closed. All buffers in the other windows become
  102.         hidden.
  103.  
  104.  
  105. Moving the cursor to other windows
  106. ----------------------------------
  107.  
  108. CTRL-W <CURSOR_DOWN>
  109. CTRL-W CTRL-J
  110. CTRL-W j    move cursor to Nth window below current one.
  111.  
  112. CTRL-W <CURSOR_UP>
  113. CTRL-W CTRL-K
  114. CTRL-W k    move cursor to Nth window above current one.
  115.  
  116. CTRL-W w
  117. CTRL-W CTRL-W    Without count: move cursor to window below current one. If
  118.         there is no window below, go to upper window.
  119.         With count: go to Nth window.
  120.  
  121. CTRL-W p
  122. CTRL-W CTRL-P    go to previous (last accessed) window.
  123.  
  124.  
  125. Moving windows around
  126. ---------------------
  127.  
  128. CTRL-W r
  129. CTRL-W CTRL-R    Rotate windows downwards. The first window becomes the second
  130.         one, the second one the third one, etc. The last window
  131.         becomes the first window. The cursor remains in the same
  132.         window.
  133.  
  134. CTRL-W R    Rotate windows upwards. The second window becomes the first
  135.         one, the third one the second one, etc. The first window
  136.         becomes the last window. The cursor remains in the same
  137.         window.
  138.  
  139. CTRL-W x
  140. CTRL-W CTRL-X    Without count: Exchange current window with next one. If there
  141.         is no next window, exchange with previous window. With count:
  142.         Exchange current window with Nth window (first window is 1).
  143.         The cursor is put in the other window.
  144.  
  145.  
  146. Window resizing
  147. ---------------
  148.  
  149. CTRL-W =    make all windows (almost) equal high.
  150.  
  151. :resize -N
  152. CTRL-W -    decrease current window height by N
  153.  
  154. :resize +N
  155. CTRL-W +    increase current window height by N
  156.  
  157. :resize [N]
  158. CTRL-W CTRL-_
  159. CTRL-W _    set current window height to N (default: highest possible)
  160.  
  161. z<nr><CR>    set current window height to nr
  162.  
  163. The option 'winheight' ('wh') is used to set the minimal window height of the
  164. current window. This option is used each time another window becomes the
  165. current window. If the option is '0' it is disabled. Set 'winheight' to a very
  166. large value, e.g. '9999', to make the current window always fill all available
  167. space. Set it to a reasonable value, e.g. '10', to make editing in the current
  168. window comfortable.
  169.  
  170. When the option 'equalalways' ('ea') is set all the windows are automatically
  171. made the same size after splitting or closing a window. If you don't set this
  172. option, splitting a window will reduce the size of the current window and
  173. leave the other windows the same. When closing a window the extra lines are
  174. given the the window above it.
  175.  
  176. The option 'commandheight' ('ch') is used to set the height of the command
  177. line. If you are annoyed by the "hit return to continue" questions for long
  178. messages, set this option to 2 or 3.
  179.  
  180. If there is only one window, resizing that window will also change the command
  181. line height. If there are several windows, resizing the current window will
  182. also change the height of the window below it (and sometimes the window above
  183. it).
  184.  
  185.  
  186. Exiting Vim with multiple windows or buffers
  187. --------------------------------------------
  188.  
  189. :qall        Exit Vim, unless there are some buffers which have been
  190.         changed. (Use :bmod to go to the next modified buffer).
  191.  
  192. :qall!        Exit Vim. Any changes to buffers are lost.
  193.  
  194. :wqall
  195. :xall        Write all changed buffers and exit Vim. If there are buffers
  196.         without a file name, which are readonly or cannot be written
  197.         for another reason, Vim is not quit. 
  198.  
  199. :wqall!
  200. :xall!        Write all changed buffers, also the ones that are readonly,
  201.         and exit Vim. If there are buffers without a file name or
  202.         cannot be written for another reason, Vim is not quit. 
  203.  
  204.  
  205. Writing with multiple buffers
  206. -----------------------------
  207.  
  208. :wall        Write all changed buffers. Buffers without a file name or
  209.         which are readonly are not written.
  210.  
  211. :wall!        Write all changed buffers, also the ones that are readonly.
  212.         Buffers without a file name are not written.
  213.  
  214.  
  215. Overview of argument and buffer list commands
  216. ---------------------------------------------
  217.  
  218.    args list            buffer list        meaning
  219. 1. :[N]argument [N]    11. :[N]buffer [N]    to arg/buf N
  220. 2. :[N]next [file ..]    12. :[N]bnext [N]    to Nth next arg/buf
  221. 3. :[N]Next [N]        13. :[N]bNext [N]    to Nth previous arg/buf
  222. 4. :[N]previous    [N]    14. :[N]bprevious [N]    to Nth previous arg/buf
  223. 5. :rewind        15. :brewind        to first arg/buf
  224. 6. :last        16. :blast        to last arg/buf
  225. 7. :all            17. :ball        edit all args/buffers
  226.             18. :unhide        edit all loaded buffers
  227.             19. :[N]bmod [N]    to Nth modified buf
  228.  
  229.  split & args list      split & buffer list     meaning                   
  230. 21. :[N]sargument [N]   31. :[N]sbuffer [N]    split + to arg/buf N           
  231. 22. :[N]snext [file ..] 32. :[N]sbnext [N]      split + to Nth next arg/buf    
  232. 23. :[N]sNext [N]       33. :[N]sbNext [N]      split + to Nth previous arg/buf
  233. 24. :[N]sprevious [N]   34. :[N]sbprevious [N]  split + to Nth previous arg/buf
  234. 25. :srewind            35. :sbrewind           split + to first arg/buf       
  235. 26. :slast              36. :sblast             split + to last arg/buf        
  236. 27. :sall        37: :sball        edit all args/buffers
  237.             38. :sunhide        edit all loaded buffers
  238.                         39. :[N]sbmod [N]       split + to Nth modified buf    
  239.  
  240. 40.    :args            list of arguments
  241. 41.    :buffers        list of buffers
  242.  
  243. The meaning of [N] depends on the command:
  244. [N] is number of buffers to go forward/backward on ?2, ?3, ?4
  245. [N] is an argument number, defaulting to current argument, for 1, 21
  246. [N] is a buffer number, defaulting to current buffer, for 11, 31
  247. [N] is a count for 17, 39
  248.  
  249. Note: ":next" is an exception, because it must accept a list of file names
  250. for compatibility with vi.
  251.  
  252.  
  253. The argument list and multiple windows
  254. --------------------------------------
  255.  
  256. The current position in the argument list can be different for each window.
  257. Remember that when doing ":e file" the position in the argument list stays
  258. the same, but you are not editing the file at that position. Thus the
  259. message (file N of M) may be misleading (this is inherited from vi).
  260.  
  261. All the entries in the argument list are added to the buffer list. Thus you
  262. can also get to them with the buffer list commands, like ":bnext".
  263.  
  264. :all
  265. :sall        Rearrange the screen to open one window for each argument.
  266.         All other windows are closed (buffers become hidden).
  267.  
  268. :[N]sargument[!] [N]
  269.         Short for ":split | argument [N]": split window and go to
  270.         Nth argument. But when there is no such argument, of the
  271.         current file cannot be abandoned, the window is not split.
  272.  
  273. :[N]snext[!] [file ..]
  274.         Short for ":split | [N]next": split window and go to Nth
  275.         next argument. But when there is no next file, or the
  276.         current file cannot be abandoned, the window is not split.
  277.  
  278. :[N]sprevious[!] [N]
  279. :[N]sNext[!] [N]
  280.         Short for ":split | Next": split window and go to Nth
  281.         previous argument. But when there is no previous file, or
  282.         the current file cannot be abandoned, the window is not
  283.         split.
  284.  
  285. :srewind[!]    Short for ":split | rewind": split window and go to first
  286.         argument. But when the current file cannot be abandoned the
  287.         window is not split.
  288.  
  289. :slast[!]    Short for ":split | last": split window and go to last
  290.         argument. But when the current file cannot be abandoned the
  291.         window is not split.
  292.  
  293.  
  294. Tag or file name under the cursor
  295. ---------------------------------
  296.  
  297. CTRL-W ]
  298. CTRL-W CTRL-]    split current window in two. Use identifier under cursor as a
  299.         tag and jump to it in the new upper window. Make new window N
  300.         high.
  301.  
  302. CTRL-W f
  303. CTRL-W CTRL-F    split current window in two. Edit file name under cursor. Like
  304.         ":split ]f", but window isn't split if the file does not exist.
  305.  
  306.  
  307. Using hidden buffers
  308. --------------------
  309.  
  310. A hidden buffer is not displayed in a window, but is still loaded into memory.
  311. This makes it possible to jump from file to file, without the need to read or
  312. write the file every time, and having to keep the file in a window.
  313.  
  314. If the option 'hidden' ('hid') is set, abandoned buffers are kept for all
  315. commands that start editing another file: ":edit", ":next", ":tag", etc. The
  316. commands that move through the buffer list make the current buffer hidden
  317. although the 'hidden' option is not set (see below).
  318.  
  319. You can make a hidden buffer not hidden, by starting to edit it with any
  320. command. Or by deleting it with the ":bdelete" command.
  321.  
  322. :files
  323. :buffers    Show all buffers. Example:
  324.  
  325.             1 #h  "/test/text" line 1
  326.             2  -  "asdf" line 0
  327.             3 % + "version.c" line 1
  328.  
  329.         Each buffer has a unique number. That number will not change,
  330.         so you can always go to a specific buffer with ":buffer N" or
  331.         "N CTRL-^", where N is the buffer number.
  332.  
  333.          '-' indicates a buffer that is not loaded. 'h' indicates a
  334.         hidden buffer: It is loaded, but currently not displayed in a
  335.         window. '%' indicates the buffer in the current window. '#'
  336.         indicates the alternate buffer for ":e #" or CTRL-^. '+'
  337.         indicates a modified buffer.
  338.  
  339. :[N]bdelete
  340. :bdelete [N]
  341.         Unload buffer [N] (default: current buffer) and delete it from
  342.         the buffer list. If the buffer was changed this fails. The
  343.         file remains unaffected. If buffer [N] is the current buffer,
  344.         the next buffer becomes the current buffer.
  345.  
  346. :[N]bdelete!
  347. :bdelete! [N]
  348.         Unload buffer [N] (default: current buffer) and delete it from
  349.         the buffer list. If the buffer was changed the changes are
  350.         lost. The file remains unaffected. If buffer [N] is the
  351.         current buffer, the next buffer becomes the current buffer.
  352.  
  353. :N,Mbdelete[!]    do :bdelete[!] for all buffers in the range N to M (inclusive).
  354.  
  355. :bdelete[!] N1 N2 ..
  356.         do :bdelete[!] for buffer N1, N2, etc.
  357.  
  358. :[N]bunload
  359. :bunload [N]
  360.         Unload buffer [N] (default: current buffer). The memory
  361.         allocated for this buffer will be freed. The buffer remains in
  362.         the buffer list. If the buffer was changed this fails. If
  363.         buffer [N] is the current buffer, the next buffer becomes the
  364.         current buffer.
  365.  
  366. :[N]bunload!
  367. :bunload! [N]
  368.         Unload buffer [N] (default: current buffer). The memory
  369.         allocated for this buffer will be freed. The buffer remains in
  370.         the buffer list. If the buffer was changed the changes are
  371.         lost. If buffer [N] is the current buffer, the next buffer
  372.         becomes the current buffer.
  373.  
  374. :N,Mbunload[!]    do :bunload[!] for all buffers in the range N to M (inclusive).
  375.  
  376. :bunload[!] N1 N2 ..
  377.         do :bunload[!] for buffer N1, N2, etc.
  378.  
  379. :[N]buffer [N]
  380.         Edit buffer [N] from the buffer list. If [N] is not given, the
  381.         current buffer remains being edited.
  382.  
  383. :[N]bnext [N]    Go to [N]th next buffer in buffer list. [N] defaults to one.
  384.  
  385. :[N]bNext [N]
  386. :[N]bprev [N]    Go to [N]th previous buffer in buffer list. [N] defaults to
  387.         one.
  388.  
  389. :brewind    Go to first buffer in buffer list
  390.  
  391. :blast        Go to last buffer in buffer list
  392.  
  393. :[N]bmodified [N]
  394.         Go to [N]th next modified buffer in buffer list
  395.  
  396. :[N]sbuffer [N]
  397.         split window and Edit buffer [N] from the buffer list. If [N]
  398.         is not given, the current buffer is edited.
  399.  
  400. :[N]sbnext [N]    split window and go to [N]th next buffer in buffer list
  401.  
  402. :[N]sbNext [N]
  403. :[N]sbprev [N]    split window and go to [N]th previous buffer in buffer list
  404.  
  405. :sbrewind    split window and go to first buffer in buffer list
  406.  
  407. :sblast        split window and go to last buffer in buffer list
  408.  
  409. :[N]sbmodified [N]
  410.         split window and go to [N]th next modified buffer in buffer list
  411.  
  412. :unhide
  413. :sunhide    Rearrange the screen to open one window for each loaded
  414.         buffer in the buffer list.
  415.  
  416. :ball
  417. :sball        Rearrange the screen to open one window for each buffer in
  418.         the buffer list.
  419.  
  420.  
  421. Memory usage limits
  422. -------------------
  423.  
  424. The option 'maxmem' ('mm') is used to set the maximal memory used for one
  425. buffer (in Kbyte). 'maxmemtot' is used to set the maximal memory used for all
  426. buffers (in Kbyte). The defaults depend on the system used. For the Amiga and
  427. MSDOS 'maxmemtot' is set depending on the amount of memory available. If you
  428. don't like Vim to swap to a file, set 'maxmem' and 'maxmemtot' to a very large
  429. value. The swap file will then only be used for recovery. If you don't want a
  430. swap file at all, set 'updatecount' to 0, or use the "-n" argument when
  431. starting Vim. Note that the 'maxmem' option is only used when a buffer is
  432. created. Changing this option does not affect buffers that have already been
  433. loaded. Thus you can set it to different values for different files.
  434. 'maxmemtot' works always.
  435.